//Kathryn Glowinski
//ScheduleConflicts.cpp
//Implementation of the ScheduleConflicts class

#include <vector>
#include <ctime>
#include <cstdlib>
#include <iostream>
#include "scheduleconflicts.h"
#include "scheduleindividual.h"

ScheduleConflicts::ScheduleConflicts(int numberOfClasses){

        numClasses = numberOfClasses;

        conflicts = new int *[numClasses];

        for (int i = 0; i < numClasses; i++){
                conflicts[i] = new int [numClasses];
        }
}

ScheduleConflicts :: ~ScheduleConflicts(){

        for (int i = 0; i < numClasses; i++){
                delete [] conflicts[i];
        }
        delete [] conflicts;
}

void ScheduleConflicts :: generateRandomly(int numClasses, double difficulty){

        for (int i = 0; i < numClasses; i++){
                for (int j = i; j < numClasses; j++){

                        if (i == j){
                                conflicts[i][j] = 0;
                        }
                        else {
                                double random = fRand(0, 1);

                                if (random < difficulty){
                                        conflicts[i][j] = 1;
                                        conflicts[j][i] = 1;
                                }
                                else {
                                        conflicts[i][j] = 0;
                                        conflicts[j][i] = 0;
                                }
                        }
                }
        }

}
double ScheduleConflicts :: fRand(double fMin, double fMax){
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

void ScheduleConflicts :: print(){

        for (int i = 0; i < numClasses; i++){
                for (int j = 0; j < numClasses; j++){
                        cout << conflicts[i][j];
                }
                cout << endl;
        }
}
